<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>旋转衍射高光谱相机</title>
  <link rel="stylesheet" href="/static/css/bootstrap.min.css">
  <link rel="stylesheet" href="/static/css/bbfont.css">
  <link rel="stylesheet" href="/static/css/style.css">
  <link rel="stylesheet" href="qv.css">
</head>
<body id="viewer" class="M1">
<div id="CCC" style="padding: 4px 6px;">
  <button class="btn btn-primary btn-sm disactive-btn" onclick="main.realtime()" id="realtime">实时</button>
  <button class="btn btn-primary btn-sm mx-1" id="history" onclick="main.history()">历史</button>
  日期:
  <input id="day" type="date" >
  任务:
  <select id="task" class="sele-comp">
  </select>
  最大帧: <label id="frm_max"></label>
  数据帧:
  <input id="frm_input" oninput="this.nextElementSibling.value=this.value" style="min-width: 60px" type="number" >
  <input oninput="this.previousElementSibling.value=this.value" id="frm_range" type="range" min="0" max="0" value="0"
         step="1" style="max-width: 400px;">
  <div class="flex-grow-1"></div>
  <button class="btn btn-primary btn-sm"  onclick="main.exportCSV(this)"><i class="fa fa-file-text"></i>下载帧信息</button>
  
</div>
<div class="d-flex d-flex flex-row" style="height: calc(100vh - 37px)">
  <div class="history position-relative">
    <div id="thumbs" class="h-100 w-100 p-1 position-absolute"
         style="overflow-y: auto;border-top: 1px solid var(--bd-gray)">
    </div>
  </div>
  <div class="flex-grow-1 d-flex flex-column">
    <div id="ctrl" class="d-flex flex-row bg-light" style="height: 28px">
      <a class="fa fa-image btn  btn-r" onclick="$dld(main.cur_task,main.cur_frame.name+'.jpg')"></a>
      <!--      <a class="fa fa-download btn  btn-r" onclick="$dld(main.cur_task,main.cur_frame.name+'.tif')"></a>-->
      <label title="对比度" class="btn-r btn"><i class="fa fa-adjust"></i>
        <input type="range" value="1" min="0" max="2" step="0.01"></label>
      <label title="亮度" class="btn-r btn"><i class="fa fa-sun-o "></i>
        <input type="range" value="1" min="0" max="2" step="0.01"></label>
      <label title="色调" class="btn-r btn"><i class="fa fa-dashboard "></i>
        <input type="range" value="0" min="0" max="360"> </label>
      <label title="饱和度" class="btn-r btn"><i class="fa fa-certificate "></i>
        <input type="range" value="1" min="0" max="2" step="0.01"> </label>
      <button title="重置" class="btn-r btn" onclick="reset()">
        <i class="fa fa-refresh"></i>
        <i class="fa fa-circle-half"></i>
      </button>
      <span id="pos"></span>
      <span id="info"></span>

    </div>
    <div id="img-viewer" class="flex-grow-1">
      <div class="x-viewer" style="position: absolute;height: 100%;width: 100%;overflow: hidden">
        <img class="x-scale" id="frame_img" alt="" src=""></div>
    </div>
  </div>
  <div class="d-flex flex-column" style="width: 350px">
    <div class="card-header">
      数据
    </div>
    <div class="flex-grow-1  position-relative">
      <div class="position-absolute h-100 w-100" style="overflow-y: auto">
        <table id="params" class="table table-sm table-hover"></table>
      </div>
    </div>
  </div>
</div>
<script src="/static/js/jquery-3.6.0.min.js"></script>
<script src="/static/js/xtool.js?12"></script>
<script src="qv.js"></script>
<script src="cam-qv.js"></script>
<script>
XPZY={
  0x0001:"高灵敏度模式10倍增益",
0x0003:'高灵敏度模式 30倍增益',
0x1101:'低噪声模式 30倍增益',
0x1103:'低噪声模式30倍增益'
}
XJGZ= {
  0x00: '待机模式',
  0x02: '1Hz拍摄模式',
  0x04: '20Hz拍摄模式',
  0x08: '曝光调节拍摄模式'
}
  show_param = (v) => {
    main.set_img(v);
    r = v.info
    main.set_params(`
        <tr><th>图像帧标识</th><td>0x${r.image_frame_header.slice(2,14).toUpperCase()}</td></tr>
<!--        0x${fmtHEX(r.image_frame_header, 12)}-->
        <tr><th>包长度</th><td>${(r.packet_length)}</td></tr>
        <tr><th>相机ID</th><td>${(r.camera_id)}</td></tr>
        <tr><th>帧号</th><td>${(r.frame_number || r.fcnt)}</td></tr>
        <tr><th>图像存储时间</th><td>${BJT(r.image_storage_time)}</td></tr>
        <tr><th>拍摄帧数</th><td>${(r.capture_frame_count)}</td></tr>
        <tr><th>曝光时间</th><td>${(r.exposure_time)}ms</td></tr>
        <tr><th>帧频</th><td>${(r.frame_rate)}</td></tr>
        <tr><th>芯片增益模式</th><td>${XPZY[r.chip_gain_mode]}</td></tr>
        <tr><th>相机工作模式</th><td>${XJGZ[r.camera_operating_mode]}</td></tr>
        <tr><th>电源电路温度</th><td>${(r.power_circuit_temperature)}</td></tr>
        <tr><th>成像芯片温度1</th><td>${(r.imaging_chip_temperature_1)}</td></tr>
        <tr><th>成像芯片温度2</th><td>${(r.imaging_chip_temperature_2)}</td></tr>
        <tr><th>接收指令计数</th><td>${(r.received_command_count)}</td></tr>
      `)
  }
  /*
  *     {n: "帧序号", k: "fcnt", r: '4X'},
    {n: "压缩比", k: "bsf", v: (v) => BSF_CONST[v] || '-', r: '2X'},
    {n: "工作模式", k: "wk", v: v => v, r: '4b'},
    {n: "曝光模式", k: "lt", v: v => v, r: '4b'},
    {n: "图像模式", k: "im", v: v => v, r: '4b'},
    {n: "输出状态", k: "ot", v: v => v, r: '4b'},
    {n: "开窗", k: "window", v: v => v, t: '窗口起始行,窗口起始列,窗口行数,窗口列数'},
    {n: "目标", k: "target", v: v => v, t: '中心行号,中心列号,像素数'},
    {n: "曝光时间", k: "exposure_t", v: v => v, u: 'μs', r: '5X'},
    {n: "平均灰度计算", k: "grayscale_c", v: v => v, r: '3X'},
    {n: "平均灰度期望", k: "grayscale_r", v: v => v, r: '5X'},
    {n: "背景阈值", k: "background_r", v: v => v, r: '3X'},
    {n: "自动曝光约束", k: "auto_exposure_t", v: v => v, u: 'μs', t: '自动曝光时间约束值', r: '5X'},
    {n: "曝光时刻", k: "ts", v: v => BJT(v)},
    {n: "输出图像帧序号", k: "imgc", v: v => v, r: '2X'},
    {n: "总包数", k: "pkgc", v: v => v, t: '图像数据总包数', r: '4X'},
    k = received_command_count
    v = v=> v.tofixed(3)
    r: 4X 2b
    u: ms / V / W ..
    a_='0x0000 0000'
  * */
  let params=[
    {n:"图像帧标识", k: "image_frame_header",v: new RawFmt('4X').X, r:'6X'},
    {n:"包长度", k:"packet_length",v: v => v, r:'3X'},
    {n:"相机ID",k:"camera_id",v: v => v,r:'1X'},
    {n:"帧号",k:"frame_number",v: v => v,r:'2X'},
    {n:"图像存储时间",k:"image_storage_time",v: BJT,u: 'μs', r:'6X'},
    {n:"拍摄帧数",k:"capture_frame_count",v: v => v,r:'2X'},
    {n:"曝光时间",k:"exposure_time",v: v => v,u: 'μs',r:'3X'},
    {n:"帧频",k:"frame_rate",v: v => v,r:'2X'},
    {n:"芯片增益模式",k:"chip_gain_mode",v: v => XPZY[v],r:'2X'},
    {n:"相机工作模式",k:"camera_operating_mode",v: v => XJGZ[v],r:'2X'},
    {n:"电源电路温度",k:"power_circuit_temperature",v: v => v,r:'2X'},
    {n:"成像芯片温度1",k:"imaging_chip_temperature_1",v: v => v,r:'2X'},
    {n:"成像芯片温度2",k:"imaging_chip_temperature_2",v: v => v,r:'2X'},
    {n:"接收指令计数",k:"received_command_count",v: v => v,r:'1X'},
  ]
  var main = new CamViewer(ins = 'ARDIS', params)
  main.realtime()
</script>
</body>
</html>
